/*
 * $Id: Box.java 161 2009-05-22 15:40:20Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.gui.swing.widget.box;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Rectangle;

import deltadesk.gui.swing.widget.AbstractWidget;


/**
 * Box.
 * 
 * @author Andreas Meyer
 * @version $Revision: 161 $
 */
public class Box extends AbstractWidget {

	private static final long serialVersionUID = -8588606866612469905L;


	/**
	 * Construct the box.
	 */
	public Box() {
		
		getInsets().set(10, 10, 10, 10);
		setOpaque(false);
		setLayout(new GridLayout());
	}

	/**
	 * @see deltadesk.gui.swing.widget.AbstractWidget#paintComponent(java.awt.Graphics2D)
	 */
	@Override
	protected void paintComponent(final Graphics2D g2) {

		final Rectangle rect = g2.getClipBounds();
		
		g2.setPaint(new GradientPaint(0, 1, new Color(225, 227, 203), 0,
				rect.height - 2, new Color(181, 176, 154)));
		g2.fillRoundRect(1, 1, rect.width - 2, rect.height - 2, 6, 6);
		
		if(hasFocus()) {
			
			g2.setColor(Color.BLACK);
			g2.drawRoundRect(1, 1, rect.width - 2, rect.height - 2, 6, 6);
		} // end if
	}

}
